package com.ruoyi.waterPrice.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.business.waterPrice.WiFeemodeY;
import com.ruoyi.waterPrice.service.IWiFeemodeYService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 年度水费计收方式定义Controller
 * 
 * @author ps
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/WiFeemodeY")
public class WiFeemodeYController extends BaseController
{
    @Autowired
    private IWiFeemodeYService wiFeemodeYService;

    private static final Logger log = LoggerFactory.getLogger(WiFeemodeYController.class);

    /**
     * 查询年度水费计收方式定义列表
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:list")
    @GetMapping("/list")
    public TableDataInfo list(WiFeemodeY wiFeemodeY)
    {
        log.info("查询年度水费计收方式定义列表 ======= " + wiFeemodeY);
        startPage();
        List<WiFeemodeY> list = wiFeemodeYService.selectWiFeemodeYList(wiFeemodeY);
        return getDataTable(list);
    }

    /**
     * 导出年度水费计收方式定义列表
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:export")
    @Log(title = "年度水费计收方式定义", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WiFeemodeY wiFeemodeY)
    {
        List<WiFeemodeY> list = wiFeemodeYService.selectWiFeemodeYList(wiFeemodeY);
        ExcelUtil<WiFeemodeY> util = new ExcelUtil<WiFeemodeY>(WiFeemodeY.class);
        util.exportExcel(response, list, "年度水费计收方式定义数据");
    }

    /**
     * 获取年度水费计收方式定义详细信息
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        log.info("获取年度水费计收方式定义详细信息 ======= " + id);
        return success(wiFeemodeYService.selectWiFeemodeYByModeYr(id));
    }

    /**
     * 新增年度水费计收方式定义
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:add")
    @Log(title = "年度水费计收方式定义", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WiFeemodeY wiFeemodeY)
    {
        log.info("新增年度水费计收方式定义 ======= " + wiFeemodeY);
        return toAjax(wiFeemodeYService.insertWiFeemodeY(wiFeemodeY));
    }

    /**
     * 修改年度水费计收方式定义
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:edit")
    @Log(title = "年度水费计收方式定义", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WiFeemodeY wiFeemodeY)
    {
        log.info("修改年度水费计收方式定义 ======= " + wiFeemodeY);
        return toAjax(wiFeemodeYService.updateWiFeemodeY(wiFeemodeY));
    }

    /**
     * 删除年度水费计收方式定义
     */
    @RequiresPermissions("waterPrice:WiFeemodeY:remove")
    @Log(title = "年度水费计收方式定义", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        log.info("删除年度水费计收方式定义 ======= " + ids);
        return toAjax(wiFeemodeYService.deleteWiFeemodeYByModeYrs(ids));
    }
}
